<template>
    <div>
        <div class="i-layout-page-header">
            <PageHeader title="基本信息" hidden-breadcrumb />
        </div>
        <Card :bordered="false" dis-hover class="ivu-mt i-table-no-border">
            <DescriptionList title="基本信息" :col="1">
                <Description term="姓名：">{{data.users[0].nickName}}</Description>
                <Description term="申请人电话：">{{data.users[0].phonenumber}}</Description>
                <!--  请假类型（1：事假，2：病假，3：婚假，4：产假，5：丧假）-->
                <Description term="请假类型：">
                    <span v-if="data.vacationType === '1'">事假</span>
                    <span v-if="data.vacationType === '2'">病假</span>
                    <span v-if="data.vacationType === '3'">婚假</span>
                    <span v-if="data.vacationType === '4'">产假</span>
                    <span v-if="data.vacationType === '5'">丧假</span>
                </Description>
                <Description term="请假原因：">{{data.leaveReson}}</Description>
                <Description term="开始时间：">{{data.startTime}}</Description>
                <Description term="结束时间：">{{data.endTime}}</Description>
                <Description term="申请时间：">{{data.addTime}}</Description>
            </DescriptionList>
            <Divider />
            <DescriptionList title="审核信息" :col="1">
                 <Description term="审核时间：">{{data.vacationAudit.auditTime}}</Description>
                 <Description term="审核人：">{{data.vacationAudit.auditMen}}</Description>
                 <Description term="审核意见：">
                     <span v-if="data.vacationAudit.auditAdvice === '1'">同意</span>
                     <span v-if="data.vacationAudit.auditAdvice === '2'">拒绝</span>
                 </Description>
                 <Description term="审批备注：">{{data.vacationAudit.auditRemark}}</Description>
             </DescriptionList>
        </Card>
    </div>
</template>
<script>
    import Vacation from "@/api/Vacation";
    export default {
        data () {
            return {
                data:''
            }
        },
        created() {
            this.getDtail();
        },
        methods:{
            // T和Z时间转换
            changeDate(oldDate) {
                var dateee = new Date(oldDate).toJSON();//这个ie不兼容，会返回1970年的时间
                var date = new Date(+new Date(dateee) + 8 * 3600 * 1000)
                    .toISOString()
                    .replace(/T/g, " ")
                    .replace(/\.[\d]{3}Z/, "");
                return date;
                /*this.data.startTime = this.changeDate(res.startTime)
                this.data.endTime = this.changeDate(res.endTime)*/
            },
            getDtail(){
                Vacation.getInfoById({
                    leaveId:this.$route.query.leaveId
                })
                    .then(res => {
                        // 返回数据
                        this.data = res;
                        this.data.startTime = this.changeDate(res.startTime)
                        this.data.endTime = this.changeDate(res.endTime)

                    })
                    .catch(err => {
                        // 异常情况
                    })
            }
        }
    }
</script>
